// pages/akey/akey.js
let app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    libraryTab:4,
    project_status:0,
    list:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if(options.libraryTab!=undefined){
      this.setData({libraryTab:options.libraryTab});
    }
    if(options.project_status!=undefined){
      this.setData({project_status:options.project_status});
    }
  },


  statisticsList:function(){
    var self = this;
    var library = this.data.libraryTab;
    var project_status = this.data.project_status;
    var params = {library:library,project_status:project_status};
    //获取统计数据  
    app.request('post', '/api/Project/akeyApi', params).then(res => {
        var list= res.data.data;
        var count = res.data.count;
        self.setData({list:list,count:count});
    }).catch(err => console.log(err));
  },


  //跳转项目列表
  showList:function(e){
    var project_status = this.data.project_status;
    var project_type = e.currentTarget.dataset.val;

    if(project_status=="mylist"){
      wx.navigateTo({
        url: '/pages/showList/showList?libraryTab='+this.data.libraryTab+'&projectMyname=1&projectCode='+project_type,
      })
    }else{
      wx.navigateTo({
          url: '/pages/showList/showList?libraryTab='+this.data.libraryTab+'&statusCode='+project_status+'&projectCode='+project_type,
      })
    }
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.statisticsList();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})